<?php

namespace Mobile\Controller;
use Home\Logic\GoodsLogic;
use Think\Page;

class BdController extends BaseController {
    public function index(){
        $userid=session('user.user_id');
         $userinfo=M('users')->find($userid); 
         $this->assign('user',$userinfo);
        $this->display();
    }
   /**
    * 商品详情页
    */ 
    public function addbd(){
        //form表单提交
       $data=I('post.');
       unset($data['__hash__']);
       $price=C('BD_PRICE');
       $data['order_amount']=$data['order_num']*$price;
       $userinfo=M('users')->find($data['user_id']);
       /*if ($userinfo['user_money']<$data['order_amount']) {
           $this->error('余额不足');
       }*/
       $data['add_time']=time();
       $data['order_sn'] = date('YmdHis').mt_rand(1000,9999);
       $res=M('bd_order')->add($data);
       if ($res) {
          $this->success('提交成功，等待管理员审核');
       }else{
        $this->error('提交失败');
       }
    } 
    
    
    public function kc_order()
    {
        $where = " user_id = {$this->user_id}";
        $order_lists=M('bd_order')->where($where)->order('order_id desc')->select();

          $this->assign('order_lists',$order_lists);
          $this->display();
    }

     public function detail()
    {
        $order_id=I('id');
        $order_lists=M('bd_order')->find($order_id);
          $this->assign('order_info',$order_lists);
          $this->display();
    }


}